package com.excel.mq;

import com.corpgovernment.common.mq.consumer.AbstractMultiTenantRocketMQConsumer;
import com.corpgovernment.common.mq.enums.MessageBizTypeEnum;
import com.excel.service.excel.ExcelImportProcessor;
import com.excel.service.excel.ExcelImportProcessorFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.common.message.MessageExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
@Component
@Slf4j
public class ExcelMQConsumer extends AbstractMultiTenantRocketMQConsumer {


    @Autowired
    private ExcelImportProcessorFactory factory;



    @Override
    protected void consume(MessageExt messageExt, ConsumeConcurrentlyContext context) {

        // 防重复
        String msgId = messageExt.getMsgId();
        String tag = messageExt.getTags();

        String msg = new String(messageExt.getBody(), StandardCharsets.UTF_8);

        ExcelImportProcessor handler = factory.getMessageHandler(tag);
        if (handler != null) {
            //handler.handleMsg(msg);
        }

    }


    @Override
    protected MessageBizTypeEnum getMessageBizType() {
        return MessageBizTypeEnum.ORG_EXCEL;
    }
}
